<%
  var slugs = Object.keys(public.tutorials._data.tutorials);
  var tutorials = _.map(slugs, function(i) { return { 'slug': i, 'author': public.tutorials._data.tutorials[i].author, 'title': public.tutorials._data.tutorials[i].title, 'date': public.tutorials._data.tutorials[i].date, 'published': public.tutorials._data.tutorials[i].published }})
  tutorials = _.sortBy(tutorials, 'date').reverse()
%>

<section class="TutorialIndex">
  <h1>TRUFFLE TUTORIAL INDEX</h1>

  <ol class="list-unstyled">
    <% for(var tutorial of tutorials){ %>
      <% if(!!tutorial.published) { %>
        <li>
          <a href="/tutorials/<%= tutorial.slug %>">
            <h2><%= tutorial.title %></h2>

            <span>
              <date><%= tutorial.date %></date> &bull; <span>BY <%=tutorial.author %></span>
            </span>

            <div>Read Article &rarr;</div>
          </a>
        </li>
      <% } %>
    <% } %>
  </ol>
</section>
